#include<iostream>
#include<sys/time.h>
#include<vector>
#include<queue>
#include<math.h>
using namespace std;
vector<int*>v;
int doTimes = 24;
vector<queue<int>>vq;
int mul = 2000;
void initial()
{
        int temp = 0;
        int temp2 = 0;
        int num = 0;
        for(int i = 8;i <= doTimes; i++)
        {
                temp2 = i * mul;
                temp = pow(2,i);
                queue<int>q;
                int *t = new int[temp];
                for(int p = 0; p < temp; p++)
                {
                        num = rand()%10 + 1;
                        q.push(num);
                        t[p] = num;
                }
                v.push_back(t);
                vq.push_back(q);
        }
}
void eight(int *m, int n)
{
	int i = 0;
	int sum9 = 0, sum10 = 0, sum11 = 0, sum12 = 0,sum13 = 0,sum14 = 0,sum15 = 0,sum16 = 0;
	int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0,sum5 = 0,sum6 = 0,sum7 = 0,sum8 = 0;
        for(int p = 0; p < n/16; p++)
        {
		i = p*16;
                sum1 += m[i];
                sum2 += m[i + 1];
                sum3 += m[i + 2];
                sum4 += m[i + 3];
		sum5 += m[i + 4];
                sum6 += m[i + 5];
                sum7 += m[i + 6];
                sum8 += m[i + 7];
        	sum9 += m[i + 8];
                sum10 += m[i + 9];
                sum11 += m[i + 10];
                sum12 += m[i + 11];
                sum13 += m[i + 12];
                sum14 += m[i + 13];
                sum15 += m[i + 14];
                sum16 += m[i + 15];
	}
        int sum = sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7 + sum8;
}
void four(int * m, int n)
{
        int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
        for(int i = 0; i < n/4; i++)
        {
                sum1 += m[i];
                sum2 += m[i + 1];
		sum3 += m[i + 2];
		sum4 += m[i + 3];
        }
        int sum = sum1 + sum2 + sum3 + sum4;
}
void tradition(int * m, int len)
{
        unsigned long long sum = 0;
        for(int i = 0; i < len; i++)
        {
                sum += m[i];
        }
}
int main()
{
        struct timeval t1,t2;
        double timeuse;
        initial();
        int temp = 0;
        int temp2 = 0;
        for(int i = 8; i <= doTimes; i++)
        {
                temp2 = i * mul;
                temp = pow(2,i);
                gettimeofday(&t1,NULL);
                
		tradition(v[i - 8], temp);
		//four(v[i - 8],temp);
		//eight(v[i - 8],temp);
		
		gettimeofday(&t2,NULL);
                timeuse = (t2.tv_sec - t1.tv_sec) + (double)(t2.tv_usec - t1.tv_usec)/1000.0;
                cout<<i<<" "<<timeuse<<endl;  //输出时间（单位：ｓ）
        }
        //getchar();
        return 0;
}
